#include <stdio.h>
#include <stdlib.h>

int descendCompare(const void* a, const void* b)
{
	return *(char*)b - *(char*)a;
}

char* descend(char input[], char output[])
{
	for(int i = 0; i < 4; i++){
		output[i] = input[i];
	}
	qsort(output, 4, sizeof(char), descendCompare);
}

int ascendCompare(const void* a, const void* b)
{
	return	*(char*)a - *(char*)b; 
}

char* ascend(char input[], char output[])
{
	for(int i = 0; i < 4; i++){
		output[i] = input[i];
	}
	qsort(output, 4, sizeof(char), ascendCompare);
}

int main()
{
	char N[32] = {0}, A[32] = {0}, B[32] = {0};
	int i_A = 0, i_B = 0;
	int number = 0;
	scanf("%s", &N);
	while(1){
		//字符串内数字降序
		descend(N, A);
		//字符串内数字升序
		ascend(N, B);
		//字符串转数字
		i_A = atoi(A);
		i_B = atoi(B);
		number = i_A - i_B;
		if(number == 0){
			printf("%s - %s = 0000\n", A, B);
			break;
		}
		if(number == 6174){
			printf("%s - %s = 6174\n", A, B);
			break;
		}
		//数字转字符串
		sprintf(N, "%d", number);
		printf("%s - %s = %s\n", A, B, N);
	}
	return 0;
}
